<template>
<div>
<!--  3使用组件-->
  <username></username>
  <password></password>
  <but></but>
</div>
</template>

<script>
// 组件的使用
// 1.引入
import username from '@/views/login/components/username'
import password from '@/views/login/components/password'
import but from '@/views/login/components/but'
import { mapState } from 'vuex'

export default {
  name: 'index.vue',
  // 2.注册
  components: {
    username,
    password,
    but
  },
  computed: {
    ...mapState(['token'])
  },
  created () {
   if (this.token){
     this.$router.push('/')
   }
  },
  watch: {
    token (newData) {
      this.$router.push('/')
    }
  }
}
</script>

<style scoped>

</style>
